package com.synthefact.daj.model;

import java.util.Set;

/**
 * A node is an element in a network. It has channels to other nodes and a
 * program that runs on the node.
 * 
 * TODO fix the wording here & elaborate.
 * 
 * Copyright (C) 2011 Synthefact
 * 
 * Based on code from (c) 1997, Wolfgang Schreiner <Wolfgang.Schreiner@risc.uni-linz.ac.at> 
 * http://www.risc.uni-linz.ac.at/software/daj
 */
public interface NodeIf {

    /**
     * Gets the network for this node.
     * 
     * @return the network for this node.
     */
    NetworkIf getNetwork();

    /**
     * Add an input channel.
     * 
     * @param the
     *            input channel to add to this node.
     */
    void addInChannel(ChannelIf channel);

    /**
     * Add an output channel.
     * 
     * @param channel
     *            the output channel to add to this node.
     */
    void addOutChannel(ChannelIf channel);

    /**
     * Gets the input channel with the given index for this node.
     * 
     * @param inChannelIndex
     *            an integer index of the channel.
     * @return The input channel for this node with the given index.
     */
    ChannelIf getInChannel(int inChannelIndex);

    /**
     * Gets the set of all the input channels for this node.
     * 
     * @return the set of all the input channels for this node.
     */
    Set<ChannelIf> getInChannelSet();

    /**
     * Gets an input channel that is not empty
     * 
     * @return A non-empty channel in the Channel set or null if all channels
     *         are empty.
     */
    ChannelIf selectInChannel();

    /**
     * Gets the output channel with the given index for this node.
     * 
     * @param outChannelIndex
     *            an integer index of the channel.
     * @return The output channel for this node with the given index.
     */
    ChannelIf getOutChannel(int outChannelIndex);

    /**
     * Gets the set of all the output channels for this node.
     * 
     * @return the set of all the output channels for this node.
     */
    Set<ChannelIf> getOutChannelSet();

    /**
     * Get the program that runs on this node.
     * 
     * @return the program that runs on this node.
     */
    ProgramIf getProgram();

    /**
     * Set an indicator that the node is ready to terminate
     */
    void setReadyToEnd();

    /**
     * Check an indicator to determine if the node is ready to terminate
     * 
     * @return true, if the node is ready to terminate
     */
    boolean isReadyToEnd();

}
